// $URL: http://mingw-lib.googlecode.com/svn/trunk/working/avcodec_to_widget_10/t_box.h $
// $Rev: 351 $
// $Author: akio.miyoshi $
// $Date:: 2010-08-03 02:54:21 +0000#$

#ifndef T_BOX_H
#define T_BOX_H

#include "stable.h"

#define USE_DECODE_THREAD 1

class T_Box
{
public:
    enum
    {
        PLAYER_HEAD_HEADGE = 2000,
        PLAYER_BUFFER_TIME = 6000,
        PLAYER_AHEAD_IMAGE = 15,
        PLAYER_ENOUGH_IMAGE = 30,
        PLAYER_IMAGE_STOCK = 60,
        //PLAYER_IMAGE_STOCK = 120,
        //PLAYER_IMAGE_STOCK = 240,
    };
    explicit T_Box();
};

class T_Box_Thread : public QThread
{
public:
    explicit T_Box_Thread()
    {
        closing(false);
    }
    void finish()
    {
        closing(true);
        this->wait_thread();
    }
//protected:
    bool closing()
    {
        return m_finishing;
    }
protected:
    void closing(bool b)
    {
        m_finishing = b;
    }
    void wait_thread() //FIXME
    {
        if(qApp->thread() != QThread::currentThread())
        {
            this->wait();
            return;
        }
        while(this->isRunning())
        {
            qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
            //msleep(1);
        }
    }
private:
    bool m_finishing;
};

#endif // T_BOX_H
